<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Init Model
 *
 */


class Category_model extends CI_Model {
	
	function __construct(){
		parent::__construct();
		
		$config = array('table'=>'category_tree');
		$this->load->library('mahana_hierarchy');
		$this->mahana_hierarchy->initialize($config);
		
	}
	
	
	//--Get Category--ypgov//
	function getCetegory($parent_id=0){
		
		//$parent_id = (int) $parent_id;
		$sql="select * from category_tree where parent_id=$parent_id order by (name) ASC";
		//die ($sql);
		
		$result = $this->db->query($sql)->result();
		
		if ($result){
			return $result;
		} else {
			return false;
		}
	}
	
	//--Get Category info--ypgov//
	function getCategory_info($catID){
		$sql="select * from category_tree where id=$catID limit 1";
		$query = $this->db->query($sql);
		$result = $query->row();
		if ($query->num_rows() > 0){
			return $result;
		} else {
			return false;
		}
	}
	
	
}
/* End of file*/	